﻿@inject IViewLocalizer Localizer
@using Microsoft.AspNetCore.Mvc.Localization
@model Skoruba.IdentityServer4.STS.Identity.ViewModels.Manage.TwoFactorAuthenticationViewModel
@{
    ViewData["Title"] = Localizer["Title"];
}

<div class="row">

    <div class="col-12">
        <h3>@ViewData["Title"]</h3>
    </div>

    @if (Model.Is2faEnabled)
    {
        if (Model.RecoveryCodesLeft == 0)
        {
            <div class="col-12">
                <div class="alert alert-danger">
                    <strong>@Localizer["NoCodes"]</strong>
                    <p>@Localizer["YouMust"] <a asp-action="GenerateRecoveryCodes">@Localizer["GenerateNewCodes"]</a> @Localizer["BeforeLogin"]</p>
                </div>
            </div>
        }
        else if (Model.RecoveryCodesLeft == 1)
        {
            <div class="col-12">
                <div class="alert alert-danger">
                    <strong>@Localizer["OneCode"]</strong>
                    <p>@Localizer["YouCanGenerateCodes"] <a asp-action="GenerateRecoveryCodes">@Localizer["GenerateNewCodes"]</a></p>
                </div>
            </div>
        }
        else if (Model.RecoveryCodesLeft <= 3)
        {
            <div class="col-12">
                <div class="alert alert-warning">
                    <strong>@Localizer["YouHave"] @Model.RecoveryCodesLeft.ToString() @Localizer["RecoveryCodeLeft"]</strong>
                    <p>@Localizer["YouShould"] <a asp-action="GenerateRecoveryCodes">@Localizer["GenerateNewCodes"]</a></p>
                </div>
            </div>
        }

        if (Model.IsMachineRemembered)
        {
            <div class="col-12 mb-3">
                <form method="post" asp-controller="Manage" asp-action="ForgetTwoFactorClient">
                    <button type="submit" class="btn btn-info">@Localizer["ForgetBrowser"]</button>
                </form>
            </div>
        }

        <div class="col-12">
            <a asp-action="Disable2faWarning" class="btn btn-dark">@Localizer["Disable2FA"]</a>
            <a asp-action="GenerateRecoveryCodesWarning" class="btn btn-danger">@Localizer["ResetCodes"]</a>
        </div>
    }

</div>

<div class="row">

    <div class="col-12 mt-3">
        <h4>@Localizer["AuthenticatorApp"]</h4>
    </div>

    <div class="col-12">
        @if (!Model.HasAuthenticator)
        {
            <a id="enable-authenticator" asp-action="EnableAuthenticator" class="btn btn-primary">@Localizer["AddAuthenticator"]</a>
        }
        else
        {
            <a id="enable-authenticator" asp-action="EnableAuthenticator" class="btn btn-primary">@Localizer["SetupAuthenticator"]</a>
            <a id="reset-authenticator" asp-action="ResetAuthenticatorWarning" class="btn btn-danger">@Localizer["ResetAuthenticator"]</a>
        }
    </div>
</div>
